/*
 * ScriptElement.h
 *
 *  Created on: 2010-6-7
 *      Author: Guobc
 */

#ifndef SCRIPTELEMENT_H_
#define SCRIPTELEMENT_H_

#include "CommonElement.h"

namespace HA {
class ScriptElement: public HA::CommonElement {
public:
	ScriptElement();

	/**
	 * Get the set of names handles by this element.
	 * @return The names to be matched that create elements of this type.
	 */
	inline string* getIds() const {
		return mIds;
	}

	/**
	 * Return the set of name that cause this element to finish.
	 * @return The names of following elements that stop further parse.
	 */
	inline string* getEnders() const {
		return mEnds;
	}

	/**
	 * Allow creating an instance of this node.
	 * @return A new instance of this node.
	 */
	inline ASTNode* newInstance() const {
		return new ScriptElement();
	}

	/**
	 * Set the new value of type attribute.
	 * @param type The new value of type attribute.
	 */
	inline void setScriptType(const string& type) {
		setAttribute("TYPE", type);
	}

	/**
	 * Get the value of type attribute.
	 * @return type The value of type attribute.
	 */
	inline string getScriptType() {
		return getAttribute("TYPE");
	}

	/**
	 * Set the code contents.
	 * @param code The new code contents of this tag.
	 */
	inline void setScriptCode(const string& code) {
		mCode = code;
	}

	/**
	 * Get the script code.
	 * Normally this is the textual contents of the children.
	 * @return The textual code contents of the tag.
	 */
	string getScriptCode();

private:
	static string mIds[];
	static string mEnds[];
	string mCode;
};
}
#endif /* SCRIPTELEMENT_H_ */
